<template>
	<view class="box">
		<van-collapse accordion :value="activeName" @change="onChange">
			<van-collapse-item :title="item.title" :name="item.id" v-for="item in data_list" :key="item.id">
				<view v-html="item.content"></view>
			</van-collapse-item>
		</van-collapse>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				port: 1,
				data_list: [], // 数据
				activeName: '', // 展开的name
			}
		},
		onLoad(e) {
			if(e.type) {
				this.port = 2;
			}
			
			this.get_data();
		},
		methods: {
			onChange(e) {
				this.activeName = e.detail;
			},
			// 获取数据
			get_data() {
				this.$http.get(this.$api.getQuestion, {
					port: this.port, // 1：用户端 2：商家端
				}).then(res => {
					if (res.data.length > 0) {
						res.data.forEach((n, k) => {
							n.content = n.content_text.replace(/<img/g, '<img class="fwb_img"');
						})
					}

					this.data_list = res.data;
				})
			}
		}
	}
</script>

<style lang="less">
	.box {
		padding: 0 46rpx;
		box-sizing: border-box;
	}

	.box /deep/ .van-cell {
		padding: 35rpx 0;
	}

	.box /deep/ .van-cell::after {
		width: 0;
	}

	.box /deep/ .van-cell__title {
		font-size: 35rpx;
		line-height: 48rpx;
		color: #000;
	}

	.box /deep/ .van-collapse-item__content {
		color: #7B7B7B;
		padding: 0 0 25rpx;
		font-size: 31rpx;
		line-height: 42rpx;
	}

	.box /deep/ .van-hairline--top-bottom:after {
		border-width: 0 0 1px 0;
	}
</style>
